<?php
$months = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre",
    "Octobre", "Novembre", "Décembre");
ini_set("date.timezone", "Europe/Paris");

$this_day = now();
$pattern = "%Y";
$str_year = mdate($pattern, $this_day);

for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year; $i > 1900; $i--) {
    $year_data[$i] = $i;
}
$day_sel = isset($selected_day)?$selected_day:1;
$month_sel = isset($selected_month)?$selected_month:1;
$year_sel = isset($year_sel)?$year_sel:1;
$selected_race_setting = array(
        'table_name' => 'doggy_race',
        'key_field' => 'id',
        'value_field' => 'race_name',
    );
$selected_region_setting = array(
        'table_name' => 'animus_sub_region',
        'key_field' => 'id',
        'value_field' => 'name',
    );
?>

<div id="nouveaux_membres">
        <?php echo form_open_multipart('home/register')?>
        <div id="view_profile" align="center">
            <div class="titre_home" style="text-transform: uppercase;">Inscription</div>
            <table id="reg" cellpadding="0" cellspacing="0" width="80%">
                <tr valign="top">
                    <td width="5%"><label for="account_name">Identifiant</label></td>
                    <td><input type="text" size="40" name="account_name" value="<?php echo set_value('account_name'); ?>"/></td>
                </tr>
                <?php if(form_error('account_name')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('account_name') ?></td></tr><?php }?>
                <tr valign="top">
                    <td><label for="email">Email</label></td>
                    <td><input type="text" size="40" name="email" value="<?php echo set_value('email'); ?>"/></td>
                </tr>
                <?php if(form_error('email')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('email') ?></td></tr><?php }?>
                <tr valign="top">
                    <td ><label for="password">Mot de passe</label></td>
                    <td><input type="password" size="40" name="password"/></td>
                </tr>
                <?php if(form_error('password')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('password') ?></td></tr><?php }?>
                <tr valign="top">
                    <td><label for="confirm_password">Confirmer le mot de passe</label></td>
                    <td><input type="password" size="40" name="confirm_password"/></td>
                </tr>
                <?php if(form_error('confirm_password')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('confirm_password') ?></td></tr><?php }?>
                <tr valign="top">
                    <td colspan="2"><label style="font-weight: bold">Ci-dessous les informations généraux de vos animaux</label></td>
                </tr>
                <tr valign="top">
                    <td><label for="fullname">Nom complet</label></td>
                    <td><input type="text" size="40" name="fullname" value="<?php echo set_value('fullname'); ?>"/></td>
                </tr>
                <?php if(form_error('fullname')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('fullname') ?></td></tr><?php }?>
                <tr valign="top">
                    <td><label for="display_name">Nom d'affichage</label></td>
                    <td><input type="text" size="40" name="display_name" value="<?php echo set_value('display_name'); ?>"/></td>
                </tr>
                <?php if(form_error('display_name')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('display_name') ?></td></tr><?php }?>
                <tr valign="top">
                    <td><label for="race">Race</label></td>
                    <td><?php echo form_dropdown('race',dropdown_data($selected_race_setting),$selected_race,'style="width:150px;"')?></td>
                </tr>
                <tr valign="top">
                    <td><label for="region">Région</label></td>
                    <td><?php echo form_dropdown('region',dropdown_data($selected_region_setting),$selected_region,'style="width:150px;"')?></td>
                </tr>
                <tr valign="top">
                    <td><label for="dob">Date de naissance</label></td>
                    <td>
                        J : <?php echo form_dropdown('birth_date', $day_data,$day_sel, 'id="day"'); ?>
                        M : <?php echo form_dropdown('birth_month', $dropdown_data,$month_sel, 'id="month"'); ?>
                        A : <?php echo form_dropdown('birth_year', $year_data, $year_sel, 'id="year"'); ?>
                    </td>
                </tr>
                <?php if($date_erreur):?>
                    <tr><td colspan="2">
                        <h4 style="color: red;"><?php echo $date_erreur;?></h4>
                    </td></tr>
                <?php endif;?>
                <tr valign="top">
                    <td><label for="gender">Sexe</label></td>
                    <td>
                    <?php
                    $male = array(
                        'name' => 'gender',
                        'id' => 'rad_male',
                        'value' => 'm',
                        'checked' => TRUE,
                        'style' => 'margin:10px',
                    );
                    $female = array(
                        'name' => 'gender',
                        'id' => 'rad_female',
                        'value' => 'f',
                        'checked' => FALSE,
                        'style' => 'margin:10px',
                    );

                    echo 'Masculin' . form_radio($male);
                    echo 'Féminin' . form_radio($female, 'Female');
                    ?>
                </td>
                </tr>
                <tr valign="top">
                    <td ><label for="address">Retapez les mots</label><br/><?php echo $captcha_img;?></td>
                    <td><input type="text" name="captcha" size="20" style="margin-top: 20px;"/></td>
                </tr>
                <?php if(form_error('captcha')){?><tr><td colspan="2" style="color: red;"><?php echo form_error('captcha') ?></td></tr><?php }?>
                <tr valign="top">
                    <td><input type="submit" name="register" id="register" value="Enregistrer"/></td>
                </tr>
            </table>
        </div>
        <?php echo form_close(); ?>
</div>
